#!/usr/bin/env python
# -*-coding:utf-8-*-
# File    : liyuqi.py


import os
import logging
from time import sleep
from selenium import webdriver

driver = webdriver.Chrome()

driver.implicitly_wait(5)

# 获取html绝对路径
file_path = os.path.join('file:///', os.getcwd(), "selenium.html")
print(file_path)

# 打开html文件
driver.get(file_path)

# 定位元素
username_ele = driver.find_element_by_css_selector("input[name='username']")
password_ele = driver.find_element_by_css_selector("input[name='password']")
login_btn = driver.find_element_by_id("sub")

# 操作元素
username_ele.send_keys("rabbit")
sleep(1)
password_ele.send_keys("love")
sleep(1)
login_btn.click()
sleep(1)

print(driver.title)
print(driver.current_url)
sleep(1)
driver.close()

driver.quit()
